var Game = Class(
	{	init:function(_map){
			if(_map){
				this.map = _map;
			}
			else {
				this.map = [];
				for(var i=0;i<8;i++){
					this.map[i]=[];
				}
				var line = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook];
				if(! this.isWhiteUp ){//swap Wang and Hou
					temp = line[3]; line[3] = line[4]; line[4] = temp;
				}
				var colors = this.isWhiteUp?[Piece.prototype.WHITE,Piece.prototype.BLACK]:[Piece.prototype.BLACK,Piece.prototype.WHITE];
				for(var i=0;i<8;i++){
					this.map[0][i] = new line[i](colors[0]);
					this.map[1][i] = new Pawn(colors[0]);
					this.map[6][i] = new Pawn(colors[1]);
					this.map[7][i] = new line[i](colors[1]);
				}
			}
			return this;
		},
		at:function(_i,_j){
			var paraLen = arguments.length;
			if(paraLen==1){
				_j = _i.j;
				_i = _i.i;
			}
			return this.map[_i][_j];
		},
		put:function(_pos, _p){
			this.map[_pos.i][_pos.j] = _p;
		}, 
		remove: function(_pos){
			this.map[_dst.i][_dst.j] = this.at(_src);
			this.map[_src.i][_src.j] =  null;
		}
	},
	function(_isWhiteUp){
		this.Status = {
			white:{
				kingMoved:false,
				RookLeftMove:false,
				RookRightMove:false
			},
			black:{
				kingMoved:false,
				RookLeftMove:false,
				RookRightMove:false
			},
			passantPawn:null
		}
		this.isWhiteUp = _isWhiteUp;
		this.map=[[],[],[],[],[],[],[],[]];
	}
);